package es.cazadoresmadridejos.propertyeditor;

import java.beans.PropertyEditorSupport;

import org.apache.commons.lang.StringUtils;

import es.cazadoresmadridejos.beans.manager.adviced.AdvicedManager;

public class AdvicedPropertyEditor extends PropertyEditorSupport  {

	private AdvicedManager manager;
	
	public AdvicedPropertyEditor(AdvicedManager manager){
		this.manager = manager;
	}
	
	@Override
	public void setAsText(String id) throws IllegalArgumentException {
		
		if(!StringUtils.isBlank(id)){
			setValue(manager.get(Long.valueOf(id)));
		}
	}

}
